﻿﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using UFIDA.U8.DB;
namespace UFIDA.U8.WAZH.NBBankSync
{
    /// <summary>
    /// 数据访问类:GL_CashTable
    /// </summary>
    public partial class GL_CashTable
    {
        public GL_CashTable()
        { }
        #region  BasicMethod
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public static bool Exists(string ino_id, int Month, int Year, string csign, string constr)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from GL_CashTable");
            strSql.Append(" where ino_id=@ino_id and iperiod=" + Month + " and iyear=" + Year + " and csign='" + csign + "'");
            SqlParameter[] parameters = {
					new SqlParameter("@ino_id", SqlDbType.NVarChar,20) 			};
            parameters[0].Value = ino_id;

            return DbHelperSQL.Exists(strSql.ToString(), constr, parameters);
        }
        public static CommandInfo DeleteCommand(string ino_id, int Month, int Year, string csign)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from GL_CashTable");
            strSql.Append(" where ino_id=@ino_id and iperiod=" + Month + " and iyear=" + Year + " and csign='" + csign + "'");
            SqlParameter[] parameters = {
					new SqlParameter("@ino_id", SqlDbType.NVarChar,20) 			};
            parameters[0].Value = ino_id;
            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);

            return cmd;
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static CommandInfo GetAddCommand(UFIDA.U8.DB.Model.GL_CashTable model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into GL_CashTable(");
            strSql.Append("iPeriod,iSignSeq,iNo_id,inid,cCashItem,md,mc,ccode,md_f,mc_f,nd_s,nc_s,cdept_id,cperson_id,ccus_id,csup_id,citem_class,citem_id,cDefine1,cDefine2,cDefine3,cDefine4,cDefine5,cDefine6,cDefine7,cDefine8,cDefine9,cDefine10,cDefine11,cDefine12,cDefine13,cDefine14,cDefine15,cDefine16,dbill_date,csign,iyear,iYPeriod,RowGuid,cexch_name)");
            strSql.Append(" values (");
            strSql.Append("@iPeriod,@iSignSeq,@iNo_id,@inid,@cCashItem,@md,@mc,@ccode,@md_f,@mc_f,@nd_s,@nc_s,@cdept_id,@cperson_id,@ccus_id,@csup_id,@citem_class,@citem_id,@cDefine1,@cDefine2,@cDefine3,@cDefine4,@cDefine5,@cDefine6,@cDefine7,@cDefine8,@cDefine9,@cDefine10,@cDefine11,@cDefine12,@cDefine13,@cDefine14,@cDefine15,@cDefine16,@dbill_date,@csign,@iyear,@iYPeriod,@RowGuid,@cexch_name)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
					new SqlParameter("@iPeriod", SqlDbType.TinyInt,1),
					new SqlParameter("@iSignSeq", SqlDbType.Int,4),
					new SqlParameter("@iNo_id", SqlDbType.SmallInt,2),
					new SqlParameter("@inid", SqlDbType.SmallInt,2),
					new SqlParameter("@cCashItem", SqlDbType.NVarChar,20),
					new SqlParameter("@md", SqlDbType.Money,8),
					new SqlParameter("@mc", SqlDbType.Money,8),
					new SqlParameter("@ccode", SqlDbType.NVarChar,40),
					new SqlParameter("@md_f", SqlDbType.Money,8),
					new SqlParameter("@mc_f", SqlDbType.Money,8),
					new SqlParameter("@nd_s", SqlDbType.Float,8),
					new SqlParameter("@nc_s", SqlDbType.Float,8),
					new SqlParameter("@cdept_id", SqlDbType.NVarChar,12),
					new SqlParameter("@cperson_id", SqlDbType.NVarChar,20),
					new SqlParameter("@ccus_id", SqlDbType.NVarChar,20),
					new SqlParameter("@csup_id", SqlDbType.NVarChar,20),
					new SqlParameter("@citem_class", SqlDbType.NVarChar,2),
					new SqlParameter("@citem_id", SqlDbType.NVarChar,60),
					new SqlParameter("@cDefine1", SqlDbType.NVarChar,20),
					new SqlParameter("@cDefine2", SqlDbType.NVarChar,20),
					new SqlParameter("@cDefine3", SqlDbType.NVarChar,20),
					new SqlParameter("@cDefine4", SqlDbType.DateTime),
					new SqlParameter("@cDefine5", SqlDbType.Int,4),
					new SqlParameter("@cDefine6", SqlDbType.DateTime),
					new SqlParameter("@cDefine7", SqlDbType.Float,8),
					new SqlParameter("@cDefine8", SqlDbType.NVarChar,4),
					new SqlParameter("@cDefine9", SqlDbType.NVarChar,8),
					new SqlParameter("@cDefine10", SqlDbType.NVarChar,60),
					new SqlParameter("@cDefine11", SqlDbType.NVarChar,120),
					new SqlParameter("@cDefine12", SqlDbType.NVarChar,120),
					new SqlParameter("@cDefine13", SqlDbType.NVarChar,120),
					new SqlParameter("@cDefine14", SqlDbType.NVarChar,120),
					new SqlParameter("@cDefine15", SqlDbType.Int,4),
					new SqlParameter("@cDefine16", SqlDbType.Float,8),
					new SqlParameter("@dbill_date", SqlDbType.DateTime),
					new SqlParameter("@csign", SqlDbType.NVarChar,8),
					new SqlParameter("@iyear", SqlDbType.SmallInt,2),
					new SqlParameter("@iYPeriod", SqlDbType.Int,4),
					new SqlParameter("@RowGuid", SqlDbType.VarChar,60),
					new SqlParameter("@cexch_name", SqlDbType.NVarChar,16)};
            parameters[0].Value = model.iPeriod;
            parameters[1].Value = model.iSignSeq;
            parameters[2].Value = model.iNo_id;
            parameters[3].Value = model.inid;
            parameters[4].Value = model.cCashItem;
            parameters[5].Value = model.md;
            parameters[6].Value = model.mc;
            parameters[7].Value = model.ccode;
            parameters[8].Value = model.md_f;
            parameters[9].Value = model.mc_f;
            parameters[10].Value = model.nd_s;
            parameters[11].Value = model.nc_s;
            parameters[12].Value = model.cdept_id;
            parameters[13].Value = model.cperson_id;
            parameters[14].Value = model.ccus_id;
            parameters[15].Value = model.csup_id;
            parameters[16].Value = model.citem_class;
            parameters[17].Value = model.citem_id;
            parameters[18].Value = model.cDefine1;
            parameters[19].Value = model.cDefine2;
            parameters[20].Value = model.cDefine3;
            parameters[21].Value = model.cDefine4;
            parameters[22].Value = model.cDefine5;
            parameters[23].Value = model.cDefine6;
            parameters[24].Value = model.cDefine7;
            parameters[25].Value = model.cDefine8;
            parameters[26].Value = model.cDefine9;
            parameters[27].Value = model.cDefine10;
            parameters[28].Value = model.cDefine11;
            parameters[29].Value = model.cDefine12;
            parameters[30].Value = model.cDefine13;
            parameters[31].Value = model.cDefine14;
            parameters[32].Value = model.cDefine15;
            parameters[33].Value = model.cDefine16;
            parameters[34].Value = model.dbill_date;
            parameters[35].Value = model.csign;
            parameters[36].Value = model.iyear;
            parameters[37].Value = model.iYPeriod;
            parameters[38].Value = model.RowGuid;
            parameters[39].Value = model.cexch_name;

            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
            return cmd;
        }



        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}

